package br.net.woodstock.tickettoride.orm;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import br.net.woodstock.rockframework.persistence.validator.jee.Reference;

@Entity
@Table(name = "ttr_application_manager")
public class ApplicationManager extends AbstractIntegerEntity {

	private static final long			serialVersionUID	= 7681651878487692367L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "application_manager_id", unique = true)
	private Integer						id;

	@Column(name = "application_manager_start_date", nullable = true)
	@Temporal(TemporalType.DATE)
	private Date						start;

	@Column(name = "application_manager_end_date", nullable = true)
	@Temporal(TemporalType.DATE)
	private Date						end;

	@Column(name = "application_manager_status", nullable = false)
	@Enumerated(EnumType.ORDINAL)
	@NotNull
	private ApplicationManagerStatus	status;

	@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "application_id", referencedColumnName = "application_id", nullable = false)
	@NotNull
	@Reference
	private Application					application;

	@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
	@NotNull
	@Reference
	private User						user;

	public ApplicationManager() {
		super();
	}

	public ApplicationManager(final Integer id) {
		super();
		this.id = id;
	}

	@Override
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final Integer id) {
		this.id = id;
	}

	public Date getStart() {
		return this.start;
	}

	public void setStart(final Date start) {
		this.start = start;
	}

	public Date getEnd() {
		return this.end;
	}

	public void setEnd(final Date end) {
		this.end = end;
	}

	public ApplicationManagerStatus getStatus() {
		return this.status;
	}

	public void setStatus(final ApplicationManagerStatus status) {
		this.status = status;
	}

	public Application getApplication() {
		return this.application;
	}

	public void setApplication(final Application application) {
		this.application = application;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(final User user) {
		this.user = user;
	}

}
